﻿using Module.FlowChart.Model;
using System;
using System.Drawing;
using System.Windows.Forms;

namespace Module.FlowChart.View
{
    internal partial class Form_CreatePage : Form
    {
        static public Form_CreatePage Main;
        static public string TypeName;
        private Form_CreatePage()
        {
            Debugger.Check(Main == null);
            Main = this;
            InitializeComponent();

            Init();
        }
        void Init()
        {
            this.SuspendLayout();
            int i = -1;
            foreach (var kv in WorkPage.WorkPageCreators)
            {
                i++;
                Button b = new Button();
                b.Size = new Size(100, 100);
                b.Location = new Point(100, 20 + i * 120);
                b.Text = kv.Key.Replace("FCWorkPage", "");
                string s = kv.Key;
                b.Click += (send, e) => { TypeName = s; this.Hide(); };
                b.Visible = true;
                b.Parent = this;
            }
            this.FormBorderStyle = FormBorderStyle.Fixed3D;
            ClientSize = new Size(300, 20 + WorkPage.WorkPageCreators.Count * 120);
            this.ResumeLayout(false);
        }

        static public string ShowWindow()
        {
            if (Main == null)
                Main = new Form_CreatePage();
            TypeName = "";
            Main.ShowDialog();
            return TypeName;
        }

        private void Form_CreatePage_Load(object sender, EventArgs e)
        {

        }
    }
}
